package com.lu.stack.api.controller;

import com.lu.stack.common.model.domain.ApplicationContextDo;
import com.lu.stack.common.model.response.R;
import com.lu.stack.nacos.model.entity.Article;
import com.lu.stack.proxy.rpc.test.RpcToArticle;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author zhanglu
 * @project lu-cloud-stack
 * @description
 * @date 2023/2/1 23:38
 */
@Slf4j
@RequestMapping("/rpc/spring-boot/test")
@RestController
public class RpcSpringbootTestController {

    @Resource
    private RpcToArticle rpcToArticle;

    @GetMapping("/t5")
    public R t5(){
        return rpcToArticle.t5();
    }

    @GetMapping("/t5s")
    public String t5s() {
        return rpcToArticle.t5s();
    }

    @GetMapping("/t5ss")
    public ApplicationContextDo t5ss() {
        return rpcToArticle.t5ss();
    }

    @GetMapping("/t6")
    public R t6(String id){
        return rpcToArticle.t6(id);
    }

    @GetMapping("/t7")
    public R t7(String id, String name){
        return rpcToArticle.t7(id, name);
    }

    @PostMapping("/t8")
    public R t8(@RequestParam String id, @RequestParam String name, @RequestParam("file") MultipartFile multipartFile){
        return rpcToArticle.t8(id, name, multipartFile);
    }

    @PostMapping("/t9")
    public R t9(String path, String id, String name){
        return rpcToArticle.t9(path, id, name);
    }

    @PostMapping("/t10")
    public R t10(String path, String id, String name, @RequestBody Map<String, Object> json){
        return rpcToArticle.t10(path, id, name, json);
    }

    @PostMapping("/t11")
    public R t11(String path, String id, String name, @RequestBody Map<String, Object> json){
        return rpcToArticle.t11(path, id, name, json);
    }

    @GetMapping("/t12")
    public R t12(String id){
        rpcToArticle.t12(id);
        return R.success();
    }

    @GetMapping("/t13")
    public R t13(String id){
        return R.success(rpcToArticle.t13(id));
    }

    @GetMapping("/t14")
    public R t14(String id){
        return R.success(rpcToArticle.t14(id));
    }

    @GetMapping("/t15")
    public R t15(String id){
        return R.success(rpcToArticle.t15(id));
    }

    @GetMapping("/t16")
    public R t16(String id){
        return R.success(rpcToArticle.t16(id));
    }

    @GetMapping("/t17")
    public R t17(String id){
        return R.success(rpcToArticle.t17(id));
    }

    @GetMapping("/t18")
    public R<List<String>> t18(String id){
        return R.success(rpcToArticle.t18(id));
    }

    @PostMapping("/t19")
    public R<List<Article>> t19(String id){
        return R.success(rpcToArticle.t19(id));
    }

    @GetMapping("/t20")
    public R<String[]> t20(String id){
        return R.success(rpcToArticle.t20(id));
    }

    @GetMapping("/t21")
    public R<Article[]> t21(String id){
        return R.success(rpcToArticle.t21(id));
    }

}
